/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Football;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ACER
 */
@Entity
@Table(name = "TICKET")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ticket.findAll", query = "SELECT t FROM Ticket t"),
    @NamedQuery(name = "Ticket.findByIdSitzplatz", query = "SELECT t FROM Ticket t WHERE t.ticketPK.idSitzplatz = :idSitzplatz"),
    @NamedQuery(name = "Ticket.findByIdMatch", query = "SELECT t FROM Ticket t WHERE t.ticketPK.idMatch = :idMatch")})
public class Ticket implements Serializable {
    @JoinColumn(name = "ID_MATCH", referencedColumnName = "ID_MATCH", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Games games;
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TicketPK ticketPK;
    @JoinColumn(name = "ID_SITZPLATZ", referencedColumnName = "ID_SITZPLATZ", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Sitzplatz sitzplatz;
    @JoinColumn(name = "ID_KUNDE", referencedColumnName = "ID_KUNDE")
    @ManyToOne
    private Kunde idKunde;

    public Ticket() {
    }

    public Ticket(TicketPK ticketPK) {
        this.ticketPK = ticketPK;
    }

    public Ticket(int idSitzplatz, int idMatch) {
        this.ticketPK = new TicketPK(idSitzplatz, idMatch);
    }

    public TicketPK getTicketPK() {
        return ticketPK;
    }

    public void setTicketPK(TicketPK ticketPK) {
        this.ticketPK = ticketPK;
    }

    public Sitzplatz getSitzplatz() {
        return sitzplatz;
    }

    public void setSitzplatz(Sitzplatz sitzplatz) {
        this.sitzplatz = sitzplatz;
    }

    public Kunde getIdKunde() {
        return idKunde;
    }

    public void setIdKunde(Kunde idKunde) {
        this.idKunde = idKunde;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ticketPK != null ? ticketPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ticket)) {
            return false;
        }
        Ticket other = (Ticket) object;
        if ((this.ticketPK == null && other.ticketPK != null) || (this.ticketPK != null && !this.ticketPK.equals(other.ticketPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Football.Ticket[ ticketPK=" + ticketPK + " ]";
    }

    public Games getGames() {
        return games;
    }

    public void setGames(Games games) {
        this.games = games;
    }
    
}
